// homepage_update.js
// Automatically update the homepage (show new posts) without refreshing
// ***LABS***

getOptions(["UI.HomepageUpdateInterval"], (function(options)
{

if(!options.HomepageUpdateInterval || window.parent != window)
	return;

var iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.id = iframe.name = "crx_riverside_plus_ajax_temp";
document.body.appendChild(iframe);
iframe.onload = (function()
{
	var d = document;
	var s = iframe.contentDocument;
	var topd = d.getElementsByClassName("t");
	var tops = s.getElementsByClassName("t");
	var identical = true;
	if(topd.length != tops.length)
		identical = false;
	else
		for(var i = 0; i < topd.length; ++i)
			if(topd[i].id != tops[i].id)
			{
				identical = false;
				break;
			}
	if(identical)
		for(var i = 0; i < topd.length; ++i)
			topd[i].innerHTML = tops[i].innerHTML;
	else
		d.body.innerHTML = s.body.innerHTML;
});
window.setInterval(function()
{
	iframe.src = "/";
}, 1000 * options.HomepageUpdateInterval);


}));
